package com.boyunv.observer.example03;
/*
 *@description
 *
 *@author boyunv
 *@create 2023/8/12 15:14
 *@version 1.0
 */

import com.boyunv.observer.example02.LotteryResult;

import java.util.PrimitiveIterator;

public abstract  class LotteryService {
   private EventManager     eventManager;

 public LotteryService() {
    //设置事件的监听类型
    eventManager = new EventManager(EventManager.EventType.MQ,EventManager.EventType.Message);
    //订阅
    eventManager.subscribe(EventManager.EventType.Message,new MessageEventListener());
    ///MQ
    eventManager.subscribe(EventManager.EventType.MQ,new MQEventListener());


 }


 public  LotteryResult lotteryAndMsg(String uId){
  LotteryResult lottery = lottery(uId);
  //发送通知
  eventManager.notify(EventManager.EventType.Message,lottery);
  eventManager.notify(EventManager.EventType.MQ,lottery);
  return lottery;
 }

 public abstract  LotteryResult lottery(String uId);
}
